package com.songlanyun.modules.advconfig.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.advconfig.dao.AdvConfigDao;
import com.songlanyun.modules.advconfig.entity.AdvConfig;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/advconfig")
public class AdvConfigController extends AbstractController {

    @Autowired
    private AdvConfigDao advConfigDao;
    /**
     * 信息
     */
    @GetMapping("/info")
    //@RequiresPermissions("pointconfig:pointconfig:info")
    public R load(){
        AdvConfig advConfig = advConfigDao.selectOne(new LambdaQueryWrapper<AdvConfig>().orderByDesc(AdvConfig::getId).last("LIMIT 1"));
        return R.ok().put("data", advConfig);
    }
    /**
     * 保存信息
     */
    @PostMapping("/set")
    //@RequiresPermissions("pointconfig:pointconfig:info")
    public R set(@RequestBody AdvConfig advConfig){
        advConfigDao.updateById(advConfig);
        return R.ok();
    }

}
